import { Graph, Path } from "@antv/x6";
import ModNode from "./ModNode";
import paramNode from "./paramNode";

export class Register {
  registerEdge() {
    /*
    注册antv/X6的边样式
     */
    Graph.registerConnector(
      "curve",
      (sourcePoint, targetPoint) => {
        const path = new Path();
        path.appendSegment(Path.createSegment("M", sourcePoint));
        path.appendSegment(
          Path.createSegment(
            "C",
            sourcePoint.x + 90,
            sourcePoint.y,
            targetPoint.x - 90,
            targetPoint.y,
            targetPoint.x,
            targetPoint.y
          )
        );
        return path.serialize();
      },
      true
    );
  }

  registerModStepNode(name) {
    /*
    注册antv/X6的编排节点样式
     */
    Graph.registerVueComponent(
      name,
      {
        template: "<mod-node></mod-node>",
        data() {
          return {};
        },
        components: {
          ModNode,
        },
      },
      true
    );
  }
  registerParamNode() {
    /*
    注册antv/X6的模组参数节点样式
     */
    Graph.registerVueComponent(
      "param-node",
      {
        template: "<param-node></param-node>",
        data() {
          return {};
        },
        components: {
          paramNode,
        },
      },
      true
    );
  }
}
